Skip to content

Help Center: add image upload for chats #96105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 7, 2024
Merged

Conversation

heavyweight
Copy link
Contributor

@heavyweight heavyweight commented Nov 6, 2024

The PR adds support for image file uploads in zendesk conversations.

Fixes https://github.com/Automattic/dotcom-forge/issues/9644

Proposed Changes

image

Let's add the possibility of sending an image in the chat!

Testing Instructions

  • Checkout branch or use live link
  • Navigate to /home?flags=help-center-experience and open the Help Center.
  • Open an existing conversation and test the image uploads

Copy link

github-actions bot commented Nov 6, 2024

@matticbot
Copy link
Contributor

matticbot commented Nov 6, 2024

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • help-center
  • odyssey-stats

To test WordPress.com changes, run install-plugin.sh $pluginSlug add/smooch-file-upload on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Nov 6, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~59 bytes added 📈 [gzipped])

name           parsed_size           gzip_size
entry-stepper       +232 B  (+0.0%)      +59 B  (+0.0%)
entry-main          +232 B  (+0.0%)      +59 B  (+0.0%)
entry-login         +232 B  (+0.0%)      +59 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~628 bytes added 📈 [gzipped])

name                               parsed_size           gzip_size
update-design-flow                      +182 B  (+0.0%)     +104 B  (+0.0%)
site-purchases                          +182 B  (+0.0%)     +105 B  (+0.0%)
purchases                               +182 B  (+0.0%)     +105 B  (+0.0%)
plans                                   +182 B  (+0.0%)     +105 B  (+0.0%)
link-in-bio-tld-flow                    +182 B  (+0.0%)      +98 B  (+0.0%)
jetpack-connect                         +182 B  (+0.0%)     +105 B  (+0.0%)
jetpack-cloud-pricing                   +182 B  (+0.0%)     +105 B  (+0.0%)
jetpack-cloud-features-comparison       +182 B  (+0.0%)     +105 B  (+0.1%)
import-hosted-site-flow                 +182 B  (+0.0%)     +107 B  (+0.0%)
email                                   +182 B  (+0.0%)     +108 B  (+0.1%)
domains                                 +182 B  (+0.0%)     +105 B  (+0.0%)
copy-site-flow                          +182 B  (+0.0%)     +106 B  (+0.1%)
checkout                                +182 B  (+0.0%)     +105 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~1513 bytes added 📈 [gzipped])

name                                                            parsed_size           gzip_size
async-load-automattic-help-center                                   +3364 B  (+0.5%)    +1117 B  (+0.6%)
async-load-signup-steps-woocommerce-install-transfer                 +182 B  (+0.6%)     +104 B  (+1.0%)
async-load-signup-steps-woocommerce-install-step-store-address       +182 B  (+0.3%)     +104 B  (+0.5%)
async-load-signup-steps-woocommerce-install-step-business-info       +182 B  (+0.2%)     +104 B  (+0.4%)
async-load-signup-steps-woocommerce-install-confirm                  +182 B  (+0.3%)     +104 B  (+0.6%)
async-load-signup-steps-website-content                              +182 B  (+0.2%)     +104 B  (+0.3%)
async-load-signup-steps-user                                         +182 B  (+0.1%)     +104 B  (+0.2%)
async-load-signup-steps-theme-selection                              +182 B  (+0.0%)     +104 B  (+0.1%)
async-load-signup-steps-test-step                                    +182 B  (+0.9%)     +104 B  (+1.5%)
async-load-signup-steps-subscribe-email                              +182 B  (+0.1%)     +104 B  (+0.2%)
async-load-signup-steps-store-features                               +182 B  (+0.4%)     +104 B  (+0.8%)
async-load-signup-steps-starting-point                               +182 B  (+0.5%)     +104 B  (+0.9%)
async-load-signup-steps-social-profiles                              +182 B  (+0.7%)     +104 B  (+1.2%)
async-load-signup-steps-site-picker                                  +182 B  (+0.1%)     +104 B  (+0.2%)
async-load-signup-steps-site-or-domain                               +182 B  (+0.4%)     +104 B  (+0.8%)
async-load-signup-steps-site-options                                 +182 B  (+0.4%)     +104 B  (+0.8%)
async-load-signup-steps-site                                         +182 B  (+0.4%)     +104 B  (+0.8%)
async-load-signup-steps-rewind-were-backing                          +182 B  (+0.8%)     +104 B  (+1.4%)
async-load-signup-steps-rewind-form-creds                            +182 B  (+0.3%)     +104 B  (+0.5%)
async-load-signup-steps-reader-landing                               +182 B  (+0.7%)     +104 B  (+1.3%)
async-load-signup-steps-page-picker                                  +182 B  (+0.0%)     +104 B  (+0.1%)
async-load-signup-steps-p2-site                                      +182 B  (+0.3%)     +104 B  (+0.7%)
async-load-signup-steps-p2-join-workspace                            +182 B  (+0.6%)     +104 B  (+1.0%)
async-load-signup-steps-p2-details                                   +182 B  (+0.7%)     +104 B  (+1.2%)
async-load-signup-steps-p2-confirm-email                             +182 B  (+0.7%)     +104 B  (+1.2%)
async-load-signup-steps-p2-complete-profile                          +182 B  (+0.2%)     +104 B  (+0.3%)
async-load-signup-steps-new-or-existing-site                         +182 B  (+0.4%)     +104 B  (+0.7%)
async-load-signup-steps-intent                                       +182 B  (+0.5%)     +104 B  (+0.8%)
async-load-signup-steps-initial-intent                               +182 B  (+0.2%)     +104 B  (+0.4%)
async-load-signup-steps-hosting-decider                              +182 B  (+0.8%)     +104 B  (+1.4%)
async-load-signup-steps-emails                                       +182 B  (+0.3%)     +104 B  (+0.5%)
async-load-signup-steps-difm-site-picker                             +182 B  (+0.1%)     +104 B  (+0.2%)
async-load-signup-steps-design-picker                                +182 B  (+0.3%)     +104 B  (+0.6%)
async-load-signup-steps-creds-permission                             +182 B  (+0.4%)     +104 B  (+0.6%)
async-load-signup-steps-creds-confirm                                +182 B  (+0.4%)     +104 B  (+0.6%)
async-load-signup-steps-courses                                      +182 B  (+0.5%)     +104 B  (+0.9%)
async-load-signup-steps-clone-start                                  +182 B  (+0.6%)     +104 B  (+1.1%)
async-load-signup-steps-clone-ready                                  +182 B  (+0.3%)     +104 B  (+0.6%)
async-load-signup-steps-clone-point                                  +182 B  (+0.1%)     +104 B  (+0.2%)
async-load-signup-steps-clone-destination                            +182 B  (+0.6%)     +104 B  (+1.0%)
async-load-signup-steps-clone-credentials                            +182 B  (+0.2%)     +104 B  (+0.5%)
async-load-signup-steps-clone-cloning                                +182 B  (+0.7%)     +104 B  (+1.1%)
async-load-calypso-signup-step-wrapper                               +182 B  (+1.2%)     +104 B  (+2.0%)
async-load-calypso-my-sites-checkout-modal                           +182 B  (+0.0%)     +102 B  (+0.0%)
async-load-calypso-components-jetpack-portal-nav                     +182 B  (+0.4%)     +102 B  (+0.7%)
async-load-calypso-blocks-editor-checkout-modal                      +182 B  (+0.0%)      +88 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@escapemanuele escapemanuele changed the title (wip) HelpCenter: add upload (wip) Help Center: add upload Nov 6, 2024
import { useCallback, useRef, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Icon, upload } from '@wordpress/icons';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also use image instead of upload to reflect what's in the designs. But we may think to ask Lucas to go with a generic upload if needed

@heavyweight heavyweight changed the title (wip) Help Center: add upload Help Center: add image upload for chats Nov 6, 2024
@heavyweight heavyweight requested a review from a team November 6, 2024 16:45
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 6, 2024
@heavyweight heavyweight marked this pull request as ready for review November 6, 2024 16:48
@agrullon95 agrullon95 self-requested a review November 6, 2024 21:17
@agrullon95 agrullon95 added the [Feature] Help Center The new integrated Help Center in Calypso that provides support tools on all screens. label Nov 6, 2024
Copy link
Contributor

@renancarvalho renancarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works fine! Great job!

I noticed that for old chats, the attachment button does not appear, only for new chats, not sure if it is intentional.
Will check code now.

@@ -99,3 +99,15 @@ export const calculateUnread = ( conversations: ZendeskConversation[] ) => {

return { unreadConversations, unreadMessages };
};

export const getClientId = ( conversations: ZendeskConversation[] ) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could reduce the nested loop to make it faster/simpler. I have tested and works great.

export const getClientId = ( conversations: ZendeskConversation[] ): string =>
	conversations
		.flatMap( ( conversation ) => conversation.messages )
		.find( ( message ) => message.source.type === 'web' && message.source.id )?.source.id || '';

@@ -87,6 +89,7 @@ export const OdieSendMessageButton = () => {
keyUpHandle={ onKeyUp }
/>
{ shouldBeDisabled && <Spinner className="odie-send-message-input-spinner" /> }
<AttachmentButton />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT if we add the shouldUseHelpCenterExperience check here instead of inside the component?, this would avoid unnecessary mounts

{shouldUseHelpCenterExperience && <AttachmentButton /> }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed this change

@@ -19,6 +19,21 @@ $blueberry-color: #3858e9;
height: 40px;
max-height: 210px;
}

.components-form-file-upload {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heavyweight I have added this to add the border and correct size

Copy link
Contributor

@renancarvalho renancarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heavyweight I loved the simplicity of this PR, you did an astonishing job!

Left minimal suggestions, it's up to you to address them.

@escapemanuele escapemanuele merged commit e782f60 into trunk Nov 7, 2024
11 checks passed
@escapemanuele escapemanuele deleted the add/smooch-file-upload branch November 7, 2024 10:29
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Help Center The new integrated Help Center in Calypso that provides support tools on all screens.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants